home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / spiff / part01 next >
Encoding:
Internet Message Format  |  1988-11-10  |  57.8 KB

  1. Subject:  v16i067:  Spiff, find approximate differences in files, Part01/04
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Daniel W Nachbar <daniel@wind.bellcore.com>
  7. Posting-number: Volume 16, Issue 67
  8. Archive-name: spiff/part01
  9.  
  10. [  This is the program Dan presented at his \fIexcellent\fP talk at
  11.    SF Usenix.  For those who weren't there, yes, Spiff is named after
  12.    the comic strip character in Calvin and Hobbes.  The "MGR" window
  13.    system mentioned in the README will be appearing here shortly.  I
  14.    repacked this submission.  --r$  ]
  15.  
  16. The well known program diff is inappropriate for some common tasks such as
  17. comparing the output of floating point calculations where roundoff errors
  18. lead diff astray and comparing program source code where some differences
  19. in the text (such as white space and comments) have no effect on the
  20. operation of the compiled code. A new program, named spiff, addresses
  21. these and other similar cases by lexical parsing of the input files and
  22. then applying a differencing algorithm to the token sequences. Spiff
  23. ignores differences between floating point numbers that are below a user
  24. settable tolerance.  Other features include user settable commenting and
  25. literal string conventions and a choice of differencing algorithm. There
  26. is also an interactive mode wherein the input texts are displayed with
  27. differences highlighted. The user can change numeric tolerances "on the
  28. fly" and spiff will adjust the highlighting accordingly.
  29.  
  30. #! /bin/sh
  31. # This is a shell archive.  Remove anything before this line, then unpack
  32. # it by saving it into a file and typing "sh file".  To overwrite existing
  33. # files, type "sh file -c".  You can also feed this as standard input via
  34. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  35. # will see the following message at the end:
  36. #        "End of archive 1 (of 4)."
  37. # Contents:  MANIFEST README Sample.1 Sample.2 Sample.3 Sample.4
  38. #   command.c command.h comment.h compare.h edit.h exact.c exact.h
  39. #   flagdefs.h float.h floatrep.c floatrep.h miller.c miller.h misc.c
  40. #   misc.h output.h parse.h strings.c strings.h token.c token.h tol.h
  41. #   visual.h
  42. # Wrapped by rsalz@papaya.bbn.com on Fri Nov 11 13:12:22 1988
  43. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  44. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  45.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  46. else
  47. echo shar: Extracting \"'MANIFEST'\" \(127 characters\)
  48. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  49. X   File Name        Archive #    Description
  50. X-----------------------------------------------------------
  51. X MANIFEST                   1    
  52. END_OF_FILE
  53. if test 127 -ne `wc -c <'MANIFEST'`; then
  54.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  55. fi
  56. # end of 'MANIFEST'
  57. fi
  58. if test -f 'README' -a "${1}" != "-c" ; then 
  59.   echo shar: Will not clobber existing file \"'README'\"
  60. else
  61. echo shar: Extracting \"'README'\" \(9702 characters\)
  62. sed "s/^X//" >'README' <<'END_OF_FILE'
  63. XINSTALLATION
  64. X    1) Change makefile settings to reflect
  65. X        ATT vs. BSD software
  66. X        termio vs. termcap
  67. X        MGR vs. no MGR        (MGR is a BELLCORE produced
  68. X                     window manager that is also available
  69. X                     free to the public.)
  70. X    2) Then, just say "make".
  71. X        If you want to "make install", you should first
  72. X        change definition of INSDIR in the makefile
  73. X
  74. X    3) to test the software say
  75. X
  76. X            spiff Sample.1 Sample.2
  77. X
  78. X        spiff should find 4 differences and
  79. X        you should see the words "added", "deleted", "changed",
  80. X        and "altered" as well as four number in stand-out mode.
  81. X
  82. X            spiff Sample.1 Sample.2 | cat
  83. X
  84. X        should produce the same output, only the differences
  85. X        should be underlined However, on many terminals the underlining
  86. X        does not appear. So try the command
  87. X
  88. X            spiff Sample.1 Sample.2 | cat -v
  89. X
  90. X        or whatever the equivalent to cat -v is on your system.
  91. X
  92. X        A more complicated test set is found in Sample.3 and Sample.4
  93. X        These files show how to use embedded commands to do things
  94. X        like change the commenting convention and tolerances on the
  95. X        fly.  Be sure to run the command with the -s option to spiff:
  96. X
  97. X            spiff -s 'command spiffword' Sample.3 Sample.4
  98. X
  99. X        These files by no means provide an exhaustive test of
  100. X        spiff's features. But they should give you some idea if things
  101. X        are working right.
  102. X
  103. X    This code (or it's closely related cousins) has been run on
  104. X    Vaxen running 4.3BSD, a CCI Power 6, some XENIX machines, and some
  105. X    other machines running System V derivatives as well as
  106. X    (thanks to eugene@ames.arpa) Cray, Amdahl and Convex machines.
  107. X
  108. X    4) Share and enjoy.
  109. X
  110. XAUTHOR'S ADDRESS
  111. X    Please send complaints, comments, praise, bug reports, etc to
  112. X        Dan Nachbar
  113. X        Bell Communications Research  (also known as BELLCORE)
  114. X        445 South St. Room 2B-389
  115. X        Morristown, NJ 07960
  116. X
  117. X            nachbar@bellcore.com
  118. X        or
  119. X            bellcore!nachbar
  120. X        or
  121. X            (201) 829-4392  (praise only, please)
  122. X
  123. XOVERVIEW OF OPERATION
  124. X
  125. XEach of two input files is read and stored in core.
  126. XThen it is parsed into a series of tokens (literal strings and
  127. Xfloating point numbers, white space is ignored).
  128. XThe token sequences are stored in core as well.
  129. XAfter both files have been parsed, a differencing algorithm is applied to
  130. Xthe token sequences.  The differencing algorithm
  131. Xproduces an edit script, which is then passed to an output routine.
  132. X
  133. XSIZE LIMITS AND OTHER DEFAULTS
  134. X        file implementing limit        name        default value
  135. Xmaximum number of lines        lines.h        _L_MAXLINES    10000
  136. X    per file
  137. Xmaximum number of tokens    token.h        K_MAXTOKENS    50000
  138. X    per file
  139. Xmaximum line length        misc.h        Z_LINELEN     1024
  140. Xmaximum word length        misc.h        Z_WORDLEN       20
  141. X (length of misc buffers for
  142. X things like literal
  143. X delimiters.
  144. X NOT length of tokens which
  145. X can be virtually any length)
  146. Xdefault absolute tolerance    tol.h        _T_ADEF           "1e-10"   
  147. Xdefault relative tolerance    tol.h        _T_RDEF           "1e-10"  
  148. Xmaximum number of commands    command.h    _C_CMDMAX      100
  149. X in effect at one time
  150. Xmaximum number of commenting    comment.h    W_COMMAX       20
  151. X conventions that can be
  152. X in effect at one time
  153. X (not including commenting
  154. X  conventions that are
  155. X  restricted to beginning
  156. X  of line)
  157. Xmaximum number of commenting    comment.h    W_BOLMAX       20
  158. X conventions that are
  159. X restricted to beginning of
  160. X line that are in effect at
  161. X one time
  162. Xmaximum number of literal    comment.h    W_LITMAX       20
  163. X string conventions that
  164. X can be in effect at one time
  165. Xmaximum number of tolerances    tol.h        _T_TOLMAX       10
  166. X that can be in effect at one
  167. X time
  168. X
  169. X
  170. XDIFFERENCES BETWEEN THE CURRENT VERSION AND THE ENCLOSED PAPER
  171. X
  172. XThe files paper.ms and paper.out contain the nroff -ms input and
  173. Xoutput respectively of a paper on spiff that was given the Summer '88
  174. XUSENIX conference in San Francisco.  Since that time many changes
  175. Xhave been made to the code.  Many flags have changed and some have
  176. Xhad their meanings reversed, see the enclosed man page for the current
  177. Xusage.  Also, there is no longer control over the
  178. Xgranularity of object used when applying the differencing algorithm.
  179. XThe current version of spiff always applies the differencing
  180. Xin terms of individual tokens.  The -t flag controls how the edit script
  181. Xis printed.  This arrangement more closely reflects the original intent
  182. Xof having multiple differencing granularities. 
  183. X
  184. XPERFORMANCE
  185. X
  186. XSpiff is big and slow.  It is big because all the storage is
  187. Xin core.  It is a straightforward but boring task to move the temporary
  188. Xstorage into a file.  Someone who cares is invited to take on the job.
  189. XSpiff is slow because whenever a choice had to be made between
  190. Xspeed of operation and ease of coding, speed of operation almost always lost.
  191. XAs the program matures it will almost certainly get smaller and faster.
  192. XObvious performance enhancements have been avoided in order to make the
  193. Xprogram available as soon as possible.
  194. X
  195. XCOPYRIGHT
  196. X
  197. XOur lawyers advise the following:
  198. X
  199. X                   Copyright (c) 1988 Bellcore
  200. X                       All Rights Reserved
  201. X  Permission is granted to copy or use this program, EXCEPT that it
  202. X  may not be sold for profit, the copyright notice must be reproduced
  203. X  on copies, and credit should be given to Bellcore where it is due.
  204. X  BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  205. X
  206. XGiven that all of the above seems to be very reasonable, there should be no
  207. Xreason for anyone to not play by the rules.
  208. X
  209. X
  210. XNAMING CONVENTIONS USED IN THE CODE
  211. X
  212. XAll symbols (functions, data declarations, macros) are named as follows:
  213. X
  214. X    L_foo    -- for names exported to other modules
  215. X            and possibly used inside the module as well.
  216. X    _L_foo    -- for names used by more than one routine
  217. X            within a module
  218. X    foo    -- for names used inside a single routine.
  219. X
  220. XEach module uses a different value for "L" -- 
  221. X    module files       letter used     implements
  222. X    spiff.c            Y    top level routines
  223. X    misc.[ch]        Z    various routines used throughout
  224. X    strings.[ch]        S    routines for handling strings
  225. X    edit.h            E    list of changes found and printed
  226. X    tol.[ch]        T    tolerances for real numbers
  227. X    token.[ch]        K    storage for objects
  228. X    float.[ch]        F    manipulation of floats
  229. X    floatrep.[ch]        R    representation of floats
  230. X    line.[ch]        L    storage for input lines
  231. X    parse.[ch]        P    parse for input files
  232. X    command.[ch]        C    storage and recognition of commands
  233. X    comment.[ch]        W    comment list maintenance
  234. X    compare.[ch]        X    comparisons of a single token
  235. X    exact.[ch]        Q    exact match differencing algorithm
  236. X    miller.[ch]        G    miller/myers differencing algorithm
  237. X    output.[ch]        O    print listing of differences
  238. X    flagdefs.h        U    define flag bits that are used in
  239. X                    several of the other modules.
  240. X                    These #defines could have been
  241. X                    included in misc.c, but were separated
  242. X                    out because of their explicit
  243. X                    communication function.
  244. X    visual.[ch]        V    screen oriented display for MGR
  245. X                    window manager, also contains
  246. X                    dummy routines for people who don't
  247. X                    have MGR 
  248. X
  249. XI haven't cleaned up visual.c yet.  It probably doesn't even compile
  250. Xin this version anyway. But since most people don't have mgr, this
  251. Xisn't urgent.
  252. X
  253. XNON-OBVIOUS DATA STRUCTURES
  254. X
  255. XThe Floating Point Representation
  256. X
  257. XFloating point numbers are stored in a struct R_flstr
  258. XThe fractional part is often called the mantissa.
  259. X
  260. XThe structure consists of
  261. X    a flag for the sign of the factional part
  262. X    the exponent in binary 
  263. X    a character string containing the fractional part
  264. X
  265. XThe structure could be converted to a float via
  266. X    atof(strcat(".",mantissa)) * (10^exponent)
  267. X
  268. XTo be properly formed, the mantissa string must:
  269. X    start with a digit between 1 and 9 (i.e. no leading zeros)
  270. X        except for the zero, in which case the mantissa is exactly "0"
  271. X    for the special case of zero, the exponent is always 0, and the
  272. X        sign is always positive. (i.e. no negative 0)
  273. X
  274. XIn other words, (except for the value 0)
  275. Xthe mantissa is a fractional number ranging
  276. Xbetween 0.1 (inclusive) and 1.0 (exclusive).
  277. XThe exponent is interpreted as a power of 10.
  278. X
  279. XLines 
  280. Xthere are three sets of lines:
  281. Ximplemented in line.c and line.h
  282. X    real_lines --
  283. X      the lines as they come from the file
  284. X    content_lines --
  285. X      a subset of reallines that excluding embedded commands
  286. Ximplemented in token.c and token.h 
  287. X    token_lines --
  288. X      a subset of content_lines consisting of those lines that
  289. X        have tokens that begin on them (literals can go on for
  290. X        more than one line)
  291. X        i.e. content_lines excluding comments and blank lines.
  292. X
  293. X
  294. XTHE STATE OF THE CODE
  295. XThings that should be added
  296. X    visual mode should handle tabs and wrapped lines
  297. X    handling huge files in chunks when in using the ordinal match
  298. X    algorithm. right now you have to parse and then diff the
  299. X    whole thing before you get any output.  often, you run out of memory.
  300. X
  301. XThings that would be nice to add
  302. X    output should optionally be expressed in real line numbers
  303. X        (i.e. including command lines)
  304. X    at present, all storage is in core. there should
  305. X        be a compile time decision to allow temporary storage
  306. X        in files rather than core. 
  307. X        that way the user could decide how to handle the
  308. X            speed/space tradeoff
  309. X    a front end that looked like diff should be added so that
  310. X        one could drop spiff into existing shell scripts
  311. X    the parser converts floats into their internal form even when
  312. X        it isn't necessary.
  313. X    in the miller/myer code, the code should check for matching
  314. X        end sequences.  it currently looks matching beginning
  315. X        sequences.
  316. X
  317. XMinor programming improvements (programming botches)
  318. X    some of the #defines should really be enumerated types
  319. X    all the routines in strings.c that alter the data at the end of
  320. X        a pointer but return void should just return the correct
  321. X        data. the current arrangement is a historical artifact
  322. X        of the days when these routines returned a status code.
  323. X        but then the code was never examined,
  324. X        so i made them void . . .
  325. X    comments should be added to the miller/myer code
  326. X    in visual mode, ask for font by name rather than number
  327. END_OF_FILE
  328. if test 9702 -ne `wc -c <'README'`; then
  329.     echo shar: \"'README'\" unpacked with wrong size!
  330. fi
  331. # end of 'README'
  332. fi
  333. if test -f 'Sample.1' -a "${1}" != "-c" ; then 
  334.   echo shar: Will not clobber existing file \"'Sample.1'\"
  335. else
  336. echo shar: Extracting \"'Sample.1'\" \(378 characters\)
  337. sed "s/^X//" >'Sample.1' <<'END_OF_FILE'
  338. Xtest file for spiff.
  339. Xthere is a word       here.
  340. Xthere is a deleted word in this line.
  341. Xthere is a word that is changed here.
  342. X
  343. Xno difference on     this line  due to      white space.
  344. Xdefault absolute tolerance should be 1e-10   
  345. Xno difference --> 0.0           different --> 0.0
  346. Xdefault relative tolerance should be 1e-10   
  347. Xno difference --> 10.           different --> 10.00000
  348. X
  349. END_OF_FILE
  350. if test 378 -ne `wc -c <'Sample.1'`; then
  351.     echo shar: \"'Sample.1'\" unpacked with wrong size!
  352. fi
  353. # end of 'Sample.1'
  354. fi
  355. if test -f 'Sample.2' -a "${1}" != "-c" ; then 
  356.   echo shar: Will not clobber existing file \"'Sample.2'\"
  357. else
  358. echo shar: Extracting \"'Sample.2'\" \(394 characters\)
  359. sed "s/^X//" >'Sample.2' <<'END_OF_FILE'
  360. Xtest file for spiff.
  361. Xthere is a word added here.
  362. Xthere is a         word in this line.
  363. Xthere is a word that is altered here.
  364. Xno difference on this line due to white space.
  365. X
  366. Xdefault absolute tolerance should be .0000000001   
  367. Xno difference --> 0.0000000001  different --> 0.00000000011
  368. Xdefault relative tolerance should be 1.0e-10   
  369. Xno difference --> 10.000000001  different --> 10.0000000011
  370. X
  371. END_OF_FILE
  372. if test 394 -ne `wc -c <'Sample.2'`; then
  373.     echo shar: \"'Sample.2'\" unpacked with wrong size!
  374. fi
  375. # end of 'Sample.2'
  376. fi
  377. if test -f 'Sample.3' -a "${1}" != "-c" ; then 
  378.   echo shar: Will not clobber existing file \"'Sample.3'\"
  379. else
  380. echo shar: Extracting \"'Sample.3'\" \(2072 characters\)
  381. sed "s/^X//" >'Sample.3' <<'END_OF_FILE'
  382. Xspiffword rem this file should be named Sample.3
  383. Xspiffword rem it is a test input file for spiff
  384. Xspiffword rem it should be compared with a file named Sample.4, to use it
  385. Xspiffword rem execute: spiff -s 'command spiffword' Sample.3 Sample.4
  386. Xspiffword rem the -s argument is  essential, otherwise spiff will
  387. Xspiffword rem will not recognized these comments for what they are.
  388. Xspiffword rem first we'll check the default tolerances.  this is the
  389. Xspiffword rem same test as is found in Sample.1/Sample.2
  390. Xdefault absolute tolerance should be 1e-10   
  391. Xno difference --> 0.0           different --> 0.0
  392. Xdefault relative tolerance should be 1e-10   
  393. Xno difference --> 10.           different --> 10.00000
  394. Xspiffword rem Note that spiff said that the differences were on lines 2 and 4
  395. Xspiffword rem of the input files even though they were really on lines 10 and
  396. Xspiffword rem of this file.
  397. Xspiffword rem That's because spiff does not count lines with commands.
  398. Xspiffword rem As part of spiff's design, it is assumed that "embedded commands"
  399. Xspiffword rem such as these are not of direct interest and have been added
  400. Xspiffword rem soley for the purpose of controlling the spiffing process.
  401. Xspiffword rem OK. Now we'll try changing some things. first, we'll add 
  402. Xspiffword rem a commenting convention, everything from # to end of line
  403. Xspiffword rem will be ignored.
  404. Xspiffword comment # $
  405. Xthere should be NO differences on this line !!!! # Nah, Nah, can't see me !!
  406. Xspiffword rem Well, that was fun. Now we'll ignore all differences
  407. Xspiffword tol i
  408. Xspiffword rem and there should be no differences the following lines
  409. Xno difference --> 0.0           NO difference --> 0.0
  410. Xno difference --> 10.           NO difference --> 10.00000
  411. Xspiffword rem now we'll set the tolerance for the second number
  412. Xspiffword rem on each line, to be lower than the others.
  413. Xspiffword tol a0.02 ; a0.01 ; a0.02
  414. Xspiffword rem and only the middle number should appear different
  415. Xnot different --> 0.0    different --> 0.0    not different --> 0.0
  416. Xspiffword rem You get the idea. Enough fun for now.
  417. XBye, Bye.
  418. END_OF_FILE
  419. if test 2072 -ne `wc -c <'Sample.3'`; then
  420.     echo shar: \"'Sample.3'\" unpacked with wrong size!
  421. fi
  422. # end of 'Sample.3'
  423. fi
  424. if test -f 'Sample.4' -a "${1}" != "-c" ; then 
  425.   echo shar: Will not clobber existing file \"'Sample.4'\"
  426. else
  427. echo shar: Extracting \"'Sample.4'\" \(2110 characters\)
  428. sed "s/^X//" >'Sample.4' <<'END_OF_FILE'
  429. Xspiffword rem this file should be named Sample.4
  430. Xspiffword rem it is a test input file for spiff
  431. Xspiffword rem it should be compared with a file named Sample.3, to use it
  432. Xspiffword rem execute: spiff -s 'command spiffword' Sample.3 Sample.4
  433. Xspiffword rem the -s argument is  essential, otherwise spiff will
  434. Xspiffword rem will not recognized these comments for what they are.
  435. Xspiffword rem first we'll check the default tolerances.  this is the
  436. Xspiffword rem same test as is found in Sample.1/Sample.2
  437. Xdefault absolute tolerance should be .0000000001   
  438. Xno difference --> 0.0000000001  different --> 0.00000000011
  439. Xdefault relative tolerance should be 1.0e-10   
  440. Xno difference --> 10.000000001  different --> 10.0000000011
  441. Xspiffword rem Note that spiff said that the differences were on lines 1 and 3
  442. Xspiffword rem of the input files even though they were really on lines 10 and
  443. Xspiffword rem of this file.
  444. Xspiffword rem That's because spiff does not count lines with commands.
  445. Xspiffword rem As part of spiff's design, it is assumed that "embedded commands"
  446. Xspiffword rem such as these are not of direct interest and have been added
  447. Xspiffword rem soley for the purpose of controlling the spiffing process.
  448. Xspiffword rem OK. Now we'll try changing some things. first, we'll add 
  449. Xspiffword rem a commenting convention, everything from # to end of line
  450. Xspiffword rem will be ignored.
  451. Xspiffword comment # $
  452. Xthere should be NO differences on this line !!!! # No difference here !!
  453. Xspiffword rem Well, that was fun. Now we'll ignore all differences
  454. Xspiffword tol i
  455. Xspiffword rem and there should be no differences the following lines
  456. Xno difference --> 0.0000000001  NO difference --> 0.00000000011
  457. Xno difference --> 10.000000001  NO difference --> 10.0000000011
  458. Xspiffword rem now we'll set the tolerance for the second number
  459. Xspiffword rem on each line, to be lower than the others.
  460. Xspiffword tol a0.02 ; a0.01 ; a0.02
  461. Xspiffword rem and only the middle number should appear different
  462. Xnot different --> 0.011  different --> 0.011  not different --> 0.011  
  463. Xspiffword rem You get the idea. Enough fun for now.
  464. XAll done.
  465. END_OF_FILE
  466. if test 2110 -ne `wc -c <'Sample.4'`; then
  467.     echo shar: \"'Sample.4'\" unpacked with wrong size!
  468. fi
  469. # end of 'Sample.4'
  470. fi
  471. if test -f 'command.c' -a "${1}" != "-c" ; then 
  472.   echo shar: Will not clobber existing file \"'command.c'\"
  473. else
  474. echo shar: Extracting \"'command.c'\" \(3236 characters\)
  475. sed "s/^X//" >'command.c' <<'END_OF_FILE'
  476. X/*                        Copyright (c) 1988 Bellcore
  477. X**                            All Rights Reserved
  478. X**       Permission is granted to copy or use this program, EXCEPT that it
  479. X**       may not be sold for profit, the copyright notice must be reproduced
  480. X**       on copies, and credit should be given to Bellcore where it is due.
  481. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  482. X*/
  483. X
  484. X
  485. X#ifndef lint
  486. Xstatic char rcsid[]= "$Header: command.c,v 1.1 88/09/15 11:33:58 daniel Rel $";
  487. X#endif
  488. X
  489. X
  490. X#include "misc.h"
  491. X#include "tol.h"
  492. X#include "comment.h"
  493. X#include "command.h"
  494. X#include "strings.h"
  495. X#include "parse.h"
  496. X
  497. X/*
  498. X**    storage for the string that signals an embedded command
  499. X*/
  500. Xstatic char _C_cmdword[Z_WORDLEN];
  501. X
  502. X/*
  503. X**    storage for the command script
  504. X*/
  505. Xstatic int _C_nextcmd = 0;
  506. Xstatic char *_C_cmds[_C_CMDMAX];
  507. X
  508. X
  509. X/*
  510. X**    add a string to the command buffer
  511. X*/
  512. Xvoid
  513. XC_addcmd(str)
  514. Xchar *str;
  515. X{
  516. X    S_savestr(&_C_cmds[_C_nextcmd++],str);
  517. X    return;
  518. X}
  519. X
  520. X/*
  521. X**    execute a single command
  522. X*/
  523. Xstatic void
  524. X_C_do_a_cmd(str)
  525. Xchar *str;
  526. X{
  527. X    /*
  528. X    **    place holder for the beginning of the string
  529. X    */
  530. X    char *beginning = str;
  531. X
  532. X    S_skipspace(&str);
  533. X
  534. X    /*
  535. X    **    set the command string to allow embedded commands
  536. X    */
  537. X    if     (!S_wordcmp(str,"command"))
  538. X    {
  539. X        S_nextword(&str);
  540. X        if (strlen(str) >= Z_WORDLEN)
  541. X        {
  542. X            Z_fatal("command word is too long");
  543. X        }
  544. X        S_wordcpy(_C_cmdword,str);
  545. X    }
  546. X    /*
  547. X    **    set the tolerances
  548. X    */
  549. X    else if (!S_wordcmp(str,"tol"))
  550. X    {
  551. X        S_nextword(&str);
  552. X        T_tolline(str);
  553. X    }
  554. X    /*
  555. X    **    add a comment specification
  556. X    */
  557. X    else if (!S_wordcmp(str,"comment"))
  558. X    {
  559. X        S_nextword(&str);
  560. X        if (strlen(str) >= Z_WORDLEN)
  561. X        {
  562. X            Z_fatal("command word is too long");
  563. X        }
  564. X        W_addcom(str,0);
  565. X    }
  566. X    else if (!S_wordcmp(str,"nestcom"))
  567. X    {
  568. X        S_nextword(&str);
  569. X        if (strlen(str) >= Z_WORDLEN)
  570. X        {
  571. X            Z_fatal("command word is too long");
  572. X        }
  573. X        W_addcom(str,1);
  574. X    }
  575. X    /*
  576. X    **    add a literal string specification
  577. X    */
  578. X    else if (!S_wordcmp(str,"literal"))
  579. X    {
  580. X        S_nextword(&str);
  581. X        if (strlen(str) >= Z_WORDLEN)
  582. X        {
  583. X            Z_fatal("command word is too long");
  584. X        }
  585. X        W_addlit(str);
  586. X    }
  587. X    else if (!S_wordcmp(str,"resetcomments"))
  588. X    {
  589. X        W_clearcoms();
  590. X    }
  591. X    else if (!S_wordcmp(str,"resetliterals"))
  592. X    {
  593. X        W_clearlits();
  594. X    }
  595. X    else if (!S_wordcmp(str,"beginchar"))
  596. X    {
  597. X        S_nextword(&str);
  598. X        W_setbolchar(*str);
  599. X    }
  600. X    else if (!S_wordcmp(str,"endchar"))
  601. X    {
  602. X        S_nextword(&str);
  603. X        W_seteolchar(*str);
  604. X    }
  605. X    else if (!S_wordcmp(str,"addalpha"))
  606. X    {
  607. X        S_nextword(&str);
  608. X        P_addalpha(str);
  609. X    }
  610. X    else if ((0 == strlen(str)) || !S_wordcmp(str,"rem") 
  611. X                    || ('#' == *str))
  612. X    {
  613. X        /* do nothing */
  614. X    }
  615. X    else
  616. X    {
  617. X        (void) sprintf(Z_err_buf,
  618. X                   "don't understand command %s\n",
  619. X                   beginning);
  620. X        Z_fatal(Z_err_buf);
  621. X    }
  622. X    return;
  623. X}
  624. X
  625. X/*
  626. X**    execute the commands in the command buffer
  627. X*/
  628. Xvoid
  629. XC_docmds()
  630. X{
  631. X    int i;
  632. X    for (i=0;i<_C_nextcmd;i++)
  633. X    {
  634. X        _C_do_a_cmd(_C_cmds[i]);
  635. X    }
  636. X    return;
  637. X}
  638. X
  639. X/*
  640. X**    disable embedded command key word recognition
  641. X*/
  642. Xvoid
  643. XC_clear_cmd()
  644. X{
  645. X    _C_cmdword[0] = '\0';
  646. X    return;
  647. X}
  648. X
  649. Xint
  650. XC_is_cmd(inline)
  651. Xchar *inline;
  652. X{
  653. X    char *ptr;
  654. X    /*
  655. X    **    see if this is a command line
  656. X    **    and if so, do the command right away
  657. X    */
  658. X    if (('\0' != _C_cmdword[0]) && (!S_wordcmp(inline,_C_cmdword)))
  659. X    {
  660. X        ptr = inline;
  661. X        S_nextword(&ptr);
  662. X        _C_do_a_cmd(ptr);
  663. X        return(1);
  664. X    }
  665. X    return(0);
  666. X}
  667. X
  668. END_OF_FILE
  669. if test 3236 -ne `wc -c <'command.c'`; then
  670.     echo shar: \"'command.c'\" unpacked with wrong size!
  671. fi
  672. # end of 'command.c'
  673. fi
  674. if test -f 'command.h' -a "${1}" != "-c" ; then 
  675.   echo shar: Will not clobber existing file \"'command.h'\"
  676. else
  677. echo shar: Extracting \"'command.h'\" \(582 characters\)
  678. sed "s/^X//" >'command.h' <<'END_OF_FILE'
  679. X/*                        Copyright (c) 1988 Bellcore
  680. X**                            All Rights Reserved
  681. X**       Permission is granted to copy or use this program, EXCEPT that it
  682. X**       may not be sold for profit, the copyright notice must be reproduced
  683. X**       on copies, and credit should be given to Bellcore where it is due.
  684. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  685. X*/
  686. X
  687. X#ifndef C_INCLUDED
  688. Xextern int C_is_cmd();
  689. Xextern void C_clear_cmd();
  690. Xextern void C_addcmd();
  691. Xextern void C_docmds();
  692. X
  693. X#define _C_CMDMAX    100
  694. X
  695. X#define C_INCLUDED
  696. X#endif
  697. END_OF_FILE
  698. if test 582 -ne `wc -c <'command.h'`; then
  699.     echo shar: \"'command.h'\" unpacked with wrong size!
  700. fi
  701. # end of 'command.h'
  702. fi
  703. if test -f 'comment.h' -a "${1}" != "-c" ; then 
  704.   echo shar: Will not clobber existing file \"'comment.h'\"
  705. else
  706. echo shar: Extracting \"'comment.h'\" \(2036 characters\)
  707. sed "s/^X//" >'comment.h' <<'END_OF_FILE'
  708. X/*                        Copyright (c) 1988 Bellcore
  709. X**                            All Rights Reserved
  710. X**       Permission is granted to copy or use this program, EXCEPT that it
  711. X**       may not be sold for profit, the copyright notice must be reproduced
  712. X**       on copies, and credit should be given to Bellcore where it is due.
  713. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  714. X*/
  715. X
  716. X#ifndef W_INCLUDED
  717. X
  718. X#include <stdio.h>
  719. X
  720. X#define _W_COMWORD    16
  721. X#define _W_COMMAX    20
  722. X#define _W_BOLMAX    20
  723. X#define _W_LITMAX    20
  724. X
  725. X/*
  726. X**    these three data structures used to be much
  727. X**        different.  eventually, the differences
  728. X**        have disappeared as the code has evolved.
  729. X**        obviously, they should now be collapsed.
  730. X**        someday . . .
  731. X*/
  732. Xtypedef struct {
  733. X    char begin[_W_COMWORD];
  734. X    char end[_W_COMWORD];
  735. X    char escape[_W_COMWORD];
  736. X} _W_bolstruct, *W_bol;
  737. X
  738. Xtypedef struct {
  739. X    char begin[_W_COMWORD];
  740. X    char end[_W_COMWORD];
  741. X    char escape[_W_COMWORD];
  742. X    int nestbit;
  743. X} _W_comstruct, *W_com;
  744. X
  745. Xtypedef struct {
  746. X    char begin[_W_COMWORD];
  747. X    char end[_W_COMWORD];
  748. X    char escape[_W_COMWORD];
  749. X} _W_litstruct, *W_lit;
  750. X
  751. X#define W_bolbegin(ptr)        (ptr->begin)
  752. X#define W_bolend(ptr)        (ptr->end)
  753. X#define W_bolescape(ptr)    (ptr->escape)
  754. X
  755. X#define W_litbegin(ptr)        (ptr->begin)
  756. X#define W_litend(ptr)        (ptr->end)
  757. X#define W_litescape(ptr)    (ptr->escape)
  758. X
  759. X#define W_combegin(ptr)        (ptr->begin)
  760. X#define W_comend(ptr)        (ptr->end)
  761. X#define W_comescape(ptr)    (ptr->escape)
  762. X
  763. Xextern char _W_bolchar;
  764. Xextern char _W_eolchar;
  765. X
  766. X#define W_setbolchar(x)        (_W_bolchar = x)
  767. X#define W_seteolchar(x)        (_W_eolchar = x)
  768. X
  769. Xextern W_bol W_isbol();
  770. Xextern W_lit W_islit();
  771. Xextern W_com W_iscom();
  772. X
  773. Xextern int W_is_bol();
  774. Xextern int W_is_lit();
  775. Xextern int W_is_com();
  776. X
  777. Xextern _W_bolstruct _W_bols[];
  778. Xextern _W_litstruct _W_lits[];
  779. Xextern _W_comstruct _W_coms[];
  780. X
  781. Xextern void W_clearcoms();
  782. Xextern void W_clearlits();
  783. Xextern void W_addcom();
  784. Xextern void W_addlit();
  785. X
  786. X#define W_BOLNULL        ((W_bol)0)
  787. X#define W_COMNULL        ((W_com)0)
  788. X#define W_LITNULL        ((W_lit)0)
  789. X
  790. X#define W_INCLUDED
  791. X#endif
  792. END_OF_FILE
  793. if test 2036 -ne `wc -c <'comment.h'`; then
  794.     echo shar: \"'comment.h'\" unpacked with wrong size!
  795. fi
  796. # end of 'comment.h'
  797. fi
  798. if test -f 'compare.h' -a "${1}" != "-c" ; then 
  799.   echo shar: Will not clobber existing file \"'compare.h'\"
  800. else
  801. echo shar: Extracting \"'compare.h'\" \(482 characters\)
  802. sed "s/^X//" >'compare.h' <<'END_OF_FILE'
  803. X/*                        Copyright (c) 1988 Bellcore
  804. X**                            All Rights Reserved
  805. X**       Permission is granted to copy or use this program, EXCEPT that it
  806. X**       may not be sold for profit, the copyright notice must be reproduced
  807. X**       on copies, and credit should be given to Bellcore where it is due.
  808. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  809. X*/
  810. X
  811. X#ifndef X_INCLUDED
  812. X
  813. Xextern int X_com();
  814. X
  815. X#define X_INCLUDED
  816. X#endif
  817. END_OF_FILE
  818. if test 482 -ne `wc -c <'compare.h'`; then
  819.     echo shar: \"'compare.h'\" unpacked with wrong size!
  820. fi
  821. # end of 'compare.h'
  822. fi
  823. if test -f 'edit.h' -a "${1}" != "-c" ; then 
  824.   echo shar: Will not clobber existing file \"'edit.h'\"
  825. else
  826. echo shar: Extracting \"'edit.h'\" \(1196 characters\)
  827. sed "s/^X//" >'edit.h' <<'END_OF_FILE'
  828. X/*                        Copyright (c) 1988 Bellcore
  829. X**                            All Rights Reserved
  830. X**       Permission is granted to copy or use this program, EXCEPT that it
  831. X**       may not be sold for profit, the copyright notice must be reproduced
  832. X**       on copies, and credit should be given to Bellcore where it is due.
  833. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  834. X*/
  835. X
  836. X/*
  837. X**    the naming information hiding conventions are incompletely implemented
  838. X**     for the edit module. I tried to clean it up once, but kept introducing
  839. X**     nasty (ie. core dump) bugs in the miller code.  I give up for now.
  840. X*/
  841. X#ifndef E_INCLUDED
  842. X
  843. X#define E_INSERT    1
  844. X#define E_DELETE    2
  845. X
  846. Xtypedef struct edt {
  847. X    struct edt *link;
  848. X    int op;
  849. X    int line1;
  850. X    int line2;
  851. X} _E_struct, *E_edit;
  852. X
  853. X#define E_setop(x,y)        ((x)->op = (y))
  854. X#define E_setl1(x,y)        ((x)->line1 = (y))
  855. X#define E_setl2(x,y)        ((x)->line2 = (y))
  856. X#define E_setnext(x,y)        ((x)->link = (y))
  857. X
  858. X#define E_getop(x)        ((x)->op)
  859. X#define E_getl1(x)        ((x)->line1)
  860. X#define E_getl2(x)        ((x)->line2)
  861. X#define E_getnext(x)        ((x)->link)
  862. X
  863. X#define E_NULL         ((E_edit) 0)
  864. X#define E_edit_alloc()    (Z_ALLOC(1,_E_struct))
  865. X
  866. X#define E_INCLUDED
  867. X
  868. X#endif
  869. X
  870. X
  871. END_OF_FILE
  872. if test 1196 -ne `wc -c <'edit.h'`; then
  873.     echo shar: \"'edit.h'\" unpacked with wrong size!
  874. fi
  875. # end of 'edit.h'
  876. fi
  877. if test -f 'exact.c' -a "${1}" != "-c" ; then 
  878.   echo shar: Will not clobber existing file \"'exact.c'\"
  879. else
  880. echo shar: Extracting \"'exact.c'\" \(2043 characters\)
  881. sed "s/^X//" >'exact.c' <<'END_OF_FILE'
  882. X/*                        Copyright (c) 1988 Bellcore
  883. X**                            All Rights Reserved
  884. X**       Permission is granted to copy or use this program, EXCEPT that it
  885. X**       may not be sold for profit, the copyright notice must be reproduced
  886. X**       on copies, and credit should be given to Bellcore where it is due.
  887. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  888. X*/
  889. X
  890. X
  891. X#ifndef lint
  892. Xstatic char rcsid[]= "$Header: exact.c,v 1.1 88/09/15 11:33:55 daniel Rel $";
  893. X#endif
  894. X
  895. X#include "misc.h"
  896. X#include "edit.h"
  897. X
  898. X/*
  899. X**    routine to compare each object with its ordinal twin
  900. X*/
  901. XE_edit
  902. XQ_do_exact(size1,size2,max_d,comflags)
  903. Xint size1;
  904. Xint size2;
  905. Xint max_d;
  906. Xint comflags;
  907. X{
  908. X    int i = 0;
  909. X    int diffcnt = 0;
  910. X    int last = Z_MIN(size1,size2);
  911. X    int next_edit = 0;
  912. X    E_edit last_ptr = E_NULL;
  913. X    int start,tmp;
  914. X    E_edit *script;
  915. X
  916. X    script = Z_ALLOC(max_d+1,E_edit);
  917. X
  918. X    if (size1 != size2)
  919. X    {
  920. X        (void) sprintf(Z_err_buf,"unequal number of tokens, %d and %d respectively\n",size1,size2);
  921. X        Z_complain(Z_err_buf);
  922. X    }
  923. X
  924. X    do
  925. X    {
  926. X        /*
  927. X        **    skip identical objects
  928. X        */
  929. X        while (i<last && (!X_com(i,i,comflags)))
  930. X        {
  931. X            i++;
  932. X        }
  933. X        start = i;
  934. X        /*
  935. X        **    see how many difference we have in a row
  936. X        */
  937. X        while (i<last && X_com(i,i,comflags))
  938. X        {
  939. X            if ((diffcnt += 2) >= max_d+1)
  940. X                Z_exceed(max_d);
  941. X            i++;
  942. X        }
  943. X        /*
  944. X        **    build the list of deletions
  945. X        */
  946. X        for(tmp=start;tmp<i;tmp++,next_edit++)
  947. X        {
  948. X            script[next_edit] = E_edit_alloc();
  949. X            E_setnext(script[next_edit],last_ptr);
  950. X            last_ptr = script[next_edit];
  951. X
  952. X            E_setop(script[next_edit],E_DELETE);
  953. X            E_setl1(script[next_edit],tmp+1);
  954. X            /* no need to set line2, it is never used */
  955. X            E_setl2(script[next_edit],0);
  956. X        }
  957. X        /*
  958. X        **    build the list of insertions
  959. X        */
  960. X        for(tmp=start;tmp<i;tmp++,next_edit++)
  961. X        {
  962. X            script[next_edit] = E_edit_alloc();
  963. X            E_setnext(script[next_edit],last_ptr);
  964. X            last_ptr = script[next_edit];
  965. X
  966. X            E_setop(script[next_edit],E_INSERT);
  967. X            E_setl1(script[next_edit],i);
  968. X            E_setl2(script[next_edit],tmp+1);
  969. X        }
  970. X    } while (i<last);
  971. X
  972. X    return(last_ptr);
  973. X}
  974. END_OF_FILE
  975. if test 2043 -ne `wc -c <'exact.c'`; then
  976.     echo shar: \"'exact.c'\" unpacked with wrong size!
  977. fi
  978. # end of 'exact.c'
  979. fi
  980. if test -f 'exact.h' -a "${1}" != "-c" ; then 
  981.   echo shar: Will not clobber existing file \"'exact.h'\"
  982. else
  983. echo shar: Extracting \"'exact.h'\" \(510 characters\)
  984. sed "s/^X//" >'exact.h' <<'END_OF_FILE'
  985. X/*                        Copyright (c) 1988 Bellcore
  986. X**                            All Rights Reserved
  987. X**       Permission is granted to copy or use this program, EXCEPT that it
  988. X**       may not be sold for profit, the copyright notice must be reproduced
  989. X**       on copies, and credit should be given to Bellcore where it is due.
  990. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  991. X*/
  992. X
  993. X#ifndef Q_INCLUDED
  994. X
  995. X#include "edit.h"
  996. X
  997. Xextern E_edit Q_do_exact();
  998. X
  999. X#define Q_INCLUDED
  1000. X
  1001. X#endif
  1002. END_OF_FILE
  1003. if test 510 -ne `wc -c <'exact.h'`; then
  1004.     echo shar: \"'exact.h'\" unpacked with wrong size!
  1005. fi
  1006. # end of 'exact.h'
  1007. fi
  1008. if test -f 'flagdefs.h' -a "${1}" != "-c" ; then 
  1009.   echo shar: Will not clobber existing file \"'flagdefs.h'\"
  1010. else
  1011. echo shar: Extracting \"'flagdefs.h'\" \(757 characters\)
  1012. sed "s/^X//" >'flagdefs.h' <<'END_OF_FILE'
  1013. X/*                        Copyright (c) 1988 Bellcore
  1014. X**                            All Rights Reserved
  1015. X**       Permission is granted to copy or use this program, EXCEPT that it
  1016. X**       may not be sold for profit, the copyright notice must be reproduced
  1017. X**       on copies, and credit should be given to Bellcore where it is due.
  1018. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1019. X*/
  1020. X
  1021. X/*
  1022. X**    flags used by both parser and comparison routines
  1023. X*/
  1024. X#define U_INCLUDE_WS    001
  1025. X
  1026. X/*
  1027. X**    flags used only by the comparison routines
  1028. X*/
  1029. X#define U_BYTE_COMPARE        002
  1030. X#define U_NO_CASE        004
  1031. X
  1032. X/*
  1033. X**    flag used by the output routine
  1034. X*/
  1035. X#define U_TOKENS        010
  1036. X
  1037. X/*
  1038. X**    flags used only by the parser
  1039. X*/
  1040. X#define U_INC_SIGN    020
  1041. X#define U_NEED_DECIMAL    040
  1042. END_OF_FILE
  1043. if test 757 -ne `wc -c <'flagdefs.h'`; then
  1044.     echo shar: \"'flagdefs.h'\" unpacked with wrong size!
  1045. fi
  1046. # end of 'flagdefs.h'
  1047. fi
  1048. if test -f 'float.h' -a "${1}" != "-c" ; then 
  1049.   echo shar: Will not clobber existing file \"'float.h'\"
  1050. else
  1051. echo shar: Extracting \"'float.h'\" \(838 characters\)
  1052. sed "s/^X//" >'float.h' <<'END_OF_FILE'
  1053. X/*                        Copyright (c) 1988 Bellcore
  1054. X**                            All Rights Reserved
  1055. X**       Permission is granted to copy or use this program, EXCEPT that it
  1056. X**       may not be sold for profit, the copyright notice must be reproduced
  1057. X**       on copies, and credit should be given to Bellcore where it is due.
  1058. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1059. X*/
  1060. X
  1061. X
  1062. X#include "floatrep.h"
  1063. X
  1064. X#ifndef F_INCLUDED
  1065. X
  1066. X/*
  1067. X**    flags for F_atof
  1068. X*/
  1069. X#define NO_USE_ALL    0
  1070. X#define USE_ALL        1
  1071. X
  1072. Xtypedef struct R_flstr *F_float;
  1073. X#define F_getexp(x)    R_getexp(x)
  1074. X#define F_getsign(x)    R_getsign(x)
  1075. X#define F_zerofloat(x)    R_zerofloat(x)
  1076. X
  1077. Xextern F_float F_atof();
  1078. X
  1079. Xextern F_float F_floatmul();
  1080. Xextern F_float F_floatmagadd();
  1081. Xextern F_float F_floatsub();
  1082. X
  1083. X#define F_null    ((F_float) 0)
  1084. X
  1085. X#define F_INCLUDED
  1086. X
  1087. X#endif
  1088. END_OF_FILE
  1089. if test 838 -ne `wc -c <'float.h'`; then
  1090.     echo shar: \"'float.h'\" unpacked with wrong size!
  1091. fi
  1092. # end of 'float.h'
  1093. fi
  1094. if test -f 'floatrep.c' -a "${1}" != "-c" ; then 
  1095.   echo shar: Will not clobber existing file \"'floatrep.c'\"
  1096. else
  1097. echo shar: Extracting \"'floatrep.c'\" \(758 characters\)
  1098. sed "s/^X//" >'floatrep.c' <<'END_OF_FILE'
  1099. X/*                        Copyright (c) 1988 Bellcore
  1100. X**                            All Rights Reserved
  1101. X**       Permission is granted to copy or use this program, EXCEPT that it
  1102. X**       may not be sold for profit, the copyright notice must be reproduced
  1103. X**       on copies, and credit should be given to Bellcore where it is due.
  1104. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1105. X*/
  1106. X
  1107. X
  1108. X#ifndef lint
  1109. Xstatic char rcsid[]= "$Header: floatrep.c,v 1.1 88/09/15 11:34:00 daniel Rel $";
  1110. X#endif
  1111. X
  1112. X#include "misc.h"
  1113. X#include "floatrep.h"
  1114. X
  1115. XR_float
  1116. XR_makefloat()
  1117. X{
  1118. X    R_float retval;
  1119. X
  1120. X    retval = Z_ALLOC(1,struct R_flstr);
  1121. X    retval->mantissa = Z_ALLOC(R_MANMAX,char);
  1122. X    return(retval);
  1123. X}
  1124. X
  1125. XR_getexp(ptr)
  1126. XR_float ptr;
  1127. X{
  1128. X    return(ptr->exponent);
  1129. X}
  1130. X
  1131. END_OF_FILE
  1132. if test 758 -ne `wc -c <'floatrep.c'`; then
  1133.     echo shar: \"'floatrep.c'\" unpacked with wrong size!
  1134. fi
  1135. # end of 'floatrep.c'
  1136. fi
  1137. if test -f 'floatrep.h' -a "${1}" != "-c" ; then 
  1138.   echo shar: Will not clobber existing file \"'floatrep.h'\"
  1139. else
  1140. echo shar: Extracting \"'floatrep.h'\" \(1372 characters\)
  1141. sed "s/^X//" >'floatrep.h' <<'END_OF_FILE'
  1142. X/*                        Copyright (c) 1988 Bellcore
  1143. X**                            All Rights Reserved
  1144. X**       Permission is granted to copy or use this program, EXCEPT that it
  1145. X**       may not be sold for profit, the copyright notice must be reproduced
  1146. X**       on copies, and credit should be given to Bellcore where it is due.
  1147. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1148. X*/
  1149. X
  1150. X/*
  1151. X** header file that defines canonical floating point structure
  1152. X**    and routines
  1153. X*/
  1154. X
  1155. X
  1156. X#ifndef  R_INCLUDED
  1157. X
  1158. X/*
  1159. X**    when evaluated to a string, the fractional part will
  1160. X**        not exceed this length
  1161. X*/
  1162. X#define R_MANMAX    200
  1163. X
  1164. X#define R_POSITIVE    0
  1165. X#define R_NEGATIVE    1
  1166. X
  1167. Xstruct  R_flstr {
  1168. X    int exponent;
  1169. X    int man_sign;
  1170. X    char *mantissa;
  1171. X};
  1172. X
  1173. Xtypedef struct R_flstr *R_float;
  1174. X
  1175. X#define R_getfrac(x)    (x->mantissa)
  1176. X
  1177. Xextern R_float R_makefloat();
  1178. X
  1179. Xextern int R_getexp();
  1180. X
  1181. X#define R_getsign(x)    (x->man_sign)
  1182. X
  1183. X/*
  1184. X**    takes a string
  1185. X*/
  1186. X#define R_setfrac(x,y)    ((void)strcpy(x->mantissa,y))
  1187. X/*
  1188. X**    takes an int
  1189. X*/
  1190. X#define R_setexp(x,y)    (x->exponent = y)
  1191. X/*
  1192. X**    takes a sign
  1193. X*/
  1194. X#define R_setsign(x,y)    (x->man_sign = y)
  1195. X
  1196. X/*
  1197. X#define R_incexp(x)    ((x->exponent)++)
  1198. X#define R_decexp(x)    ((x->exponent)--)
  1199. X*/
  1200. X
  1201. X#define R_setzero(x)    R_setfrac(x,"0");R_setexp(x,0);R_setsign(x,R_POSITIVE)
  1202. X
  1203. X#define R_zerofloat(x)    ((0 == x->exponent) && (!strcmp(x->mantissa,"0")))
  1204. X
  1205. X#define R_INCLUDED
  1206. X
  1207. X#endif
  1208. END_OF_FILE
  1209. if test 1372 -ne `wc -c <'floatrep.h'`; then
  1210.     echo shar: \"'floatrep.h'\" unpacked with wrong size!
  1211. fi
  1212. # end of 'floatrep.h'
  1213. fi
  1214. if test -f 'miller.c' -a "${1}" != "-c" ; then 
  1215.   echo shar: Will not clobber existing file \"'miller.c'\"
  1216. else
  1217. echo shar: Extracting \"'miller.c'\" \(2663 characters\)
  1218. sed "s/^X//" >'miller.c' <<'END_OF_FILE'
  1219. X/*                        Copyright (c) 1988 Bellcore
  1220. X**                            All Rights Reserved
  1221. X**       Permission is granted to copy or use this program, EXCEPT that it
  1222. X**       may not be sold for profit, the copyright notice must be reproduced
  1223. X**       on copies, and credit should be given to Bellcore where it is due.
  1224. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1225. X*/
  1226. X
  1227. X
  1228. X#ifndef lint
  1229. Xstatic char rcsid[]= "$Header: miller.c,v 1.1 88/09/15 11:33:56 daniel Rel $";
  1230. X#endif
  1231. X
  1232. X#include "misc.h"
  1233. X#include "token.h"
  1234. X#include "edit.h"
  1235. X
  1236. X#define MAXT    K_MAXTOKENS
  1237. X#define ORIGIN (max_obj/2)
  1238. X
  1239. X#define MILLER_CHATTER    100
  1240. X
  1241. X/*
  1242. X**    totally opaque miller/myers code
  1243. X**        hacked from a version provided by the author
  1244. X*/
  1245. X
  1246. X
  1247. XE_edit
  1248. XG_do_miller(m,n,max_d,comflags)
  1249. Xint m;
  1250. Xint n;
  1251. Xint max_d;
  1252. Xint comflags;
  1253. X{
  1254. X    int    max_obj = m + n;
  1255. X    int
  1256. X    lower,
  1257. X    upper,
  1258. X    d,
  1259. X    k,
  1260. X    row,
  1261. X    col;
  1262. X    E_edit new;
  1263. X
  1264. X#ifdef STATIC_MEM
  1265. X    static E_edit script[MAXT+1];
  1266. X    static int last_d[MAXT+1];
  1267. X#else
  1268. X    E_edit *script;
  1269. X    int *last_d;
  1270. X    /*
  1271. X    **    make space for the two big arrays
  1272. X    **        these could probably be smaller if I
  1273. X    **        understood this algorithm at all
  1274. X    **        as is, i just shoe horned it into my program.
  1275. X    **    be sure to allocate max_obj + 1 objects as was done
  1276. X    **        in original miller/myers code
  1277. X    */
  1278. X    script = Z_ALLOC(max_obj+1,E_edit);
  1279. X    last_d = Z_ALLOC(max_obj+1,int);
  1280. X
  1281. X#endif
  1282. X    for (row=0;row < m && row < n && X_com(row,row,comflags) == 0; ++row)
  1283. X        ;
  1284. X    last_d[ORIGIN] = row;
  1285. X    script[ORIGIN] = E_NULL;
  1286. X    lower = (row == m) ? ORIGIN+1 : ORIGIN - 1;
  1287. X    upper = (row == n) ? ORIGIN-1 : ORIGIN + 1;
  1288. X    if (lower > upper)
  1289. X    {
  1290. X        /*
  1291. X        **    the files are identical
  1292. X        */
  1293. X        return(E_NULL);
  1294. X    }
  1295. X    for (d = 1; d <= max_d; ++d) {
  1296. X        for (k = lower; k<= upper; k+= 2) {
  1297. X            new = E_edit_alloc();
  1298. X
  1299. X            if (k == ORIGIN-d || k!= ORIGIN+d && last_d[k+1] >= last_d[k-1]) {
  1300. X                row = last_d[k+1]+1;
  1301. X                E_setnext(new,script[k+1]);
  1302. X                E_setop(new,E_DELETE);
  1303. X            } else {
  1304. X                row = last_d[k-1];
  1305. X                E_setnext(new,script[k-1]);
  1306. X                E_setop(new,E_INSERT);
  1307. X            }
  1308. X
  1309. X            E_setl1(new,row);
  1310. X            col = row + k - ORIGIN;
  1311. X            E_setl2(new,col);
  1312. X            script[k] = new;
  1313. X
  1314. X            while (row < m && col < n && X_com(row,col,comflags) == 0) {
  1315. X                ++row;
  1316. X                ++col;
  1317. X            }
  1318. X            last_d[k] = row;
  1319. X            if (row == m && col == n) {
  1320. X                return(script[k]);
  1321. X            }
  1322. X            if (row == m)
  1323. X                lower = k+2;
  1324. X            if (col == n)
  1325. X                upper = k-2;
  1326. X        }
  1327. X        --lower;
  1328. X        ++upper;
  1329. X#ifndef NOCHATTER
  1330. X        if ((d > 0) && (0 == (d % MILLER_CHATTER)))
  1331. X        {
  1332. X            (void) sprintf(Z_err_buf,
  1333. X                "found %d differences\n",
  1334. X                d);
  1335. X            Z_chatter(Z_err_buf);
  1336. X        }
  1337. X#endif
  1338. X    }
  1339. X    Z_exceed(max_d);
  1340. X    /*
  1341. X    **    dummy lines to shut up lint
  1342. X    */
  1343. X    Z_fatal("fell off end of do_miller\n");
  1344. X    return(E_NULL);
  1345. X}
  1346. END_OF_FILE
  1347. if test 2663 -ne `wc -c <'miller.c'`; then
  1348.     echo shar: \"'miller.c'\" unpacked with wrong size!
  1349. fi
  1350. # end of 'miller.c'
  1351. fi
  1352. if test -f 'miller.h' -a "${1}" != "-c" ; then 
  1353.   echo shar: Will not clobber existing file \"'miller.h'\"
  1354. else
  1355. echo shar: Extracting \"'miller.h'\" \(511 characters\)
  1356. sed "s/^X//" >'miller.h' <<'END_OF_FILE'
  1357. X/*                        Copyright (c) 1988 Bellcore
  1358. X**                            All Rights Reserved
  1359. X**       Permission is granted to copy or use this program, EXCEPT that it
  1360. X**       may not be sold for profit, the copyright notice must be reproduced
  1361. X**       on copies, and credit should be given to Bellcore where it is due.
  1362. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1363. X*/
  1364. X
  1365. X#ifndef G_INCLUDED
  1366. X
  1367. X#include "edit.h"
  1368. X
  1369. Xextern E_edit G_do_miller();
  1370. X
  1371. X#define G_INCLUDED
  1372. X
  1373. X#endif
  1374. END_OF_FILE
  1375. if test 511 -ne `wc -c <'miller.h'`; then
  1376.     echo shar: \"'miller.h'\" unpacked with wrong size!
  1377. fi
  1378. # end of 'miller.h'
  1379. fi
  1380. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  1381.   echo shar: Will not clobber existing file \"'misc.c'\"
  1382. else
  1383. echo shar: Extracting \"'misc.c'\" \(1953 characters\)
  1384. sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  1385. X/*                        Copyright (c) 1988 Bellcore
  1386. X**                            All Rights Reserved
  1387. X**       Permission is granted to copy or use this program, EXCEPT that it
  1388. X**       may not be sold for profit, the copyright notice must be reproduced
  1389. X**       on copies, and credit should be given to Bellcore where it is due.
  1390. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1391. X*/
  1392. X
  1393. X
  1394. X#ifndef lint
  1395. Xstatic char rcsid[]= "$Header: misc.c,v 1.1 88/09/15 11:34:01 daniel Rel $";
  1396. X#endif
  1397. X
  1398. X#include <stdio.h>
  1399. X#include "misc.h"
  1400. X#include "visual.h"
  1401. X#include "output.h"
  1402. X
  1403. X/*
  1404. X**    various routines used throughout the program
  1405. X*/
  1406. X
  1407. Xstatic int _Z_qflag = 0;
  1408. X
  1409. Xvoid
  1410. XZ_setquiet()
  1411. X{
  1412. X    _Z_qflag = 1;
  1413. X}
  1414. X
  1415. Xchar Z_err_buf[Z_LINELEN];
  1416. X
  1417. X#ifndef NOCHATTER
  1418. X/*
  1419. X**    I/O coverup to reassure users with HUGE files
  1420. X**    that spiff is doing something
  1421. X*/
  1422. Xvoid
  1423. XZ_chatter(str)
  1424. Xchar *str;
  1425. X{
  1426. X    if (!_Z_qflag)
  1427. X    {
  1428. X        (void) fputs("spiff -- ",stderr);
  1429. X        (void) fputs(str,stderr);
  1430. X    }
  1431. X}
  1432. X#endif
  1433. X
  1434. X/*
  1435. X**    complain unless you've been told to be quiet
  1436. X*/
  1437. Xvoid
  1438. XZ_complain(str)
  1439. Xchar *str;
  1440. X{
  1441. X    if (!_Z_qflag)
  1442. X        (void) fputs(str,stderr);
  1443. X}
  1444. X
  1445. X/*
  1446. X**    quit with an error code
  1447. X*/
  1448. Xstatic void
  1449. X_Z_errexit()
  1450. X{
  1451. X    (void) exit(2);
  1452. X}
  1453. X
  1454. X/*
  1455. X**    complain and die
  1456. X*/
  1457. Xvoid
  1458. X_Z_qfatal(str)
  1459. Xchar *str;
  1460. X{
  1461. X    V_cleanup();    /* try reset the device to normal */
  1462. X    O_cleanup();    /*  "    "    "     "   "    "    */
  1463. X    Z_complain(str);
  1464. X    _Z_errexit();
  1465. X}
  1466. X
  1467. X/*
  1468. X**    scream and die
  1469. X*/
  1470. Xvoid
  1471. XZ_fatal(str)
  1472. Xchar *str;
  1473. X{
  1474. X    V_cleanup();    /* try reset the device to normal */
  1475. X    O_cleanup();    /*  "    "    "     "   "    "    */
  1476. X    (void) fputs(str,stderr);
  1477. X    _Z_errexit();
  1478. X}
  1479. X
  1480. X/*
  1481. X**    allocate memory with error checking
  1482. X*/
  1483. Xint*
  1484. X_Z_myalloc(k)
  1485. Xint k;
  1486. X{
  1487. X    int *tmp;
  1488. X    if (tmp = (int*) calloc((unsigned)k,(unsigned)1))
  1489. X    {
  1490. X        return(tmp);
  1491. X    }
  1492. X    Z_fatal("Out of Memory\n");
  1493. X    return(tmp);    /* boilerplate to shut up lint */
  1494. X}
  1495. X
  1496. Xvoid
  1497. XZ_exceed(d)
  1498. Xint d;
  1499. X{
  1500. X    (void) sprintf(Z_err_buf,
  1501. X        "The files differ in more than %d places\n", d);
  1502. X    _Z_qfatal(Z_err_buf);
  1503. X}
  1504. END_OF_FILE
  1505. if test 1953 -ne `wc -c <'misc.c'`; then
  1506.     echo shar: \"'misc.c'\" unpacked with wrong size!
  1507. fi
  1508. # end of 'misc.c'
  1509. fi
  1510. if test -f 'misc.h' -a "${1}" != "-c" ; then 
  1511.   echo shar: Will not clobber existing file \"'misc.h'\"
  1512. else
  1513. echo shar: Extracting \"'misc.h'\" \(1269 characters\)
  1514. sed "s/^X//" >'misc.h' <<'END_OF_FILE'
  1515. X/*                        Copyright (c) 1988 Bellcore
  1516. X**                            All Rights Reserved
  1517. X**       Permission is granted to copy or use this program, EXCEPT that it
  1518. X**       may not be sold for profit, the copyright notice must be reproduced
  1519. X**       on copies, and credit should be given to Bellcore where it is due.
  1520. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1521. X*/
  1522. X
  1523. X#ifndef Z_INCLUDED
  1524. X
  1525. X/*
  1526. X**    make sure that if we have a XENIX system, that
  1527. X**    we also treat it as an AT and T derivative
  1528. X*/
  1529. X#ifdef XENIX
  1530. X#ifndef ATT
  1531. X#define ATT
  1532. X#endif
  1533. X#endif
  1534. X
  1535. X#define    Z_LINELEN    1024
  1536. X#define    Z_WORDLEN      20
  1537. X
  1538. Xextern char Z_err_buf[];
  1539. X
  1540. X/*
  1541. X**    helpful macros
  1542. X*/
  1543. X#define Z_ABS(x)    (( (x) < (0) )? (-(x)):(x))
  1544. X#define Z_MIN(x,y)    (( (x) < (y) )? (x):(y))
  1545. X#define Z_MAX(x,y)    (( (x) > (y) )? (x):(y))
  1546. X
  1547. X#define Z_ALLOC(n,type)    ((type*) _Z_myalloc((n) * sizeof (type)))
  1548. Xextern int *_Z_myalloc();
  1549. X
  1550. X/*
  1551. X**    lines needed to shut up lint
  1552. X*/
  1553. Xextern char *sprintf();
  1554. Xextern char *strcat();
  1555. Xextern char *strncat();
  1556. Xextern char *strcpy();
  1557. Xextern char *strncpy();
  1558. Xextern char *malloc();
  1559. X
  1560. Xextern void Z_complain();
  1561. Xextern void Z_fatal();
  1562. Xextern void Z_exceed();
  1563. Xextern void Z_setquiet();
  1564. X#ifndef NOCHATTER
  1565. Xextern void Z_chatter();
  1566. X#endif
  1567. X
  1568. X#define Z_INCLUDED
  1569. X#endif
  1570. END_OF_FILE
  1571. if test 1269 -ne `wc -c <'misc.h'`; then
  1572.     echo shar: \"'misc.h'\" unpacked with wrong size!
  1573. fi
  1574. # end of 'misc.h'
  1575. fi
  1576. if test -f 'output.h' -a "${1}" != "-c" ; then 
  1577.   echo shar: Will not clobber existing file \"'output.h'\"
  1578. else
  1579. echo shar: Extracting \"'output.h'\" \(513 characters\)
  1580. sed "s/^X//" >'output.h' <<'END_OF_FILE'
  1581. X/*                        Copyright (c) 1988 Bellcore
  1582. X**                            All Rights Reserved
  1583. X**       Permission is granted to copy or use this program, EXCEPT that it
  1584. X**       may not be sold for profit, the copyright notice must be reproduced
  1585. X**       on copies, and credit should be given to Bellcore where it is due.
  1586. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1587. X*/
  1588. X
  1589. X
  1590. X#ifndef O_INCLUDED
  1591. X
  1592. Xextern void O_output();
  1593. Xextern void O_cleanup();
  1594. X
  1595. X#define O_INCLUDED
  1596. X
  1597. X#endif
  1598. END_OF_FILE
  1599. if test 513 -ne `wc -c <'output.h'`; then
  1600.     echo shar: \"'output.h'\" unpacked with wrong size!
  1601. fi
  1602. # end of 'output.h'
  1603. fi
  1604. if test -f 'parse.h' -a "${1}" != "-c" ; then 
  1605.   echo shar: Will not clobber existing file \"'parse.h'\"
  1606. else
  1607. echo shar: Extracting \"'parse.h'\" \(469 characters\)
  1608. sed "s/^X//" >'parse.h' <<'END_OF_FILE'
  1609. X/*                        Copyright (c) 1988 Bellcore
  1610. X**                            All Rights Reserved
  1611. X**       Permission is granted to copy or use this program, EXCEPT that it
  1612. X**       may not be sold for profit, the copyright notice must be reproduced
  1613. X**       on copies, and credit should be given to Bellcore where it is due.
  1614. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1615. X*/
  1616. X
  1617. Xextern void P_file_parse();
  1618. Xextern void P_addalpha();
  1619. END_OF_FILE
  1620. if test 469 -ne `wc -c <'parse.h'`; then
  1621.     echo shar: \"'parse.h'\" unpacked with wrong size!
  1622. fi
  1623. # end of 'parse.h'
  1624. fi
  1625. if test -f 'strings.c' -a "${1}" != "-c" ; then 
  1626.   echo shar: Will not clobber existing file \"'strings.c'\"
  1627. else
  1628. echo shar: Extracting \"'strings.c'\" \(2859 characters\)
  1629. sed "s/^X//" >'strings.c' <<'END_OF_FILE'
  1630. X/*                        Copyright (c) 1988 Bellcore
  1631. X**                            All Rights Reserved
  1632. X**       Permission is granted to copy or use this program, EXCEPT that it
  1633. X**       may not be sold for profit, the copyright notice must be reproduced
  1634. X**       on copies, and credit should be given to Bellcore where it is due.
  1635. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1636. X*/
  1637. X
  1638. X
  1639. X#ifndef lint
  1640. Xstatic char rcsid[]= "$Header: strings.c,v 1.1 88/09/15 11:33:54 daniel Rel $";
  1641. X#endif
  1642. X
  1643. X#include <ctype.h>
  1644. X#include "misc.h"
  1645. X#include "strings.h"
  1646. X
  1647. X/*
  1648. X**    routines for handling strings.
  1649. X**        several routines manipulate  "words"
  1650. X**        a "word" is a string not containing whitespace
  1651. X*/
  1652. X
  1653. X/*
  1654. X**    copy a single word. similar to  strcpy
  1655. X*/
  1656. Xvoid
  1657. XS_wordcpy(to,from)
  1658. Xchar *to, *from;
  1659. X{
  1660. X    while ((*from != '\0') && isprint(*from) && (!isspace(*from)))
  1661. X    {
  1662. X        *to++ = *from++;
  1663. X    }
  1664. X    *to = '\0';
  1665. X    return;
  1666. X}
  1667. X
  1668. X/*
  1669. X**    find the next whitespace character.  The address of the pointer
  1670. X**        is passed and the pointer itself is changed.
  1671. X*/
  1672. Xvoid
  1673. XS_skipword(theptr)
  1674. Xchar **theptr;
  1675. X{
  1676. X    while((**theptr != '\0') && isprint(**theptr) && (!isspace(**theptr)))
  1677. X    {
  1678. X        (*theptr)++;    /* increment the pointer, NOT the pointer
  1679. X                    to the pointer */
  1680. X    }
  1681. X    return;
  1682. X}
  1683. X
  1684. X/*
  1685. X**    find the next non-whitespace character.  The address of the pointer
  1686. X**        is passed and the pointer itself is changed.
  1687. X*/
  1688. Xvoid
  1689. XS_skipspace(theptr)
  1690. Xchar **theptr;
  1691. X{
  1692. X    while((**theptr != '\0') && isspace(**theptr))
  1693. X    {
  1694. X        (*theptr)++;    /* increment the pointer, NOT the pointer
  1695. X                    to the pointer */
  1696. X    }
  1697. X    return;
  1698. X}
  1699. X
  1700. X/*
  1701. X**    move the pointer to the beginning of the next word
  1702. X*/
  1703. Xvoid
  1704. XS_nextword(theptr)
  1705. Xchar **theptr;
  1706. X{
  1707. X    S_skipword(theptr);
  1708. X    S_skipspace(theptr);
  1709. X    return;
  1710. X}
  1711. X
  1712. X/*
  1713. X**    see if the first string is a prefix of the second
  1714. X**        returns 0 if yes
  1715. X**        non zero if now
  1716. X**        sigh -- the way strcmp does
  1717. X*/
  1718. Xint
  1719. XS_wordcmp(s1,s2)
  1720. Xchar *s1,*s2;
  1721. X{
  1722. X    return(strncmp(s1,s2,strlen(s2)));
  1723. X}
  1724. X
  1725. X/*
  1726. X**    chop off any trailing zeros on a string
  1727. X**        but leave one zero if there are only zeros
  1728. X*/
  1729. Xvoid
  1730. XS_trimzeros(str)
  1731. Xchar *str;
  1732. X{
  1733. X    /*
  1734. X    **    end starts out pointing at the null terminator
  1735. X    */
  1736. X    char *end = str + strlen(str);
  1737. X
  1738. X    /*
  1739. X    **    if there is more than one character left in the string
  1740. X    */
  1741. X    while(end > (str+1))
  1742. X    {
  1743. X        --end;
  1744. X        if ('0' == *end)
  1745. X        {
  1746. X            *end = '\0';
  1747. X        }
  1748. X        else
  1749. X        {
  1750. X            return;
  1751. X        }
  1752. X    }
  1753. X    return;
  1754. X}
  1755. X
  1756. X/*
  1757. X**    save a copy of the string
  1758. X*/
  1759. Xvoid
  1760. XS_savestr(to,from)
  1761. Xchar **to,*from;
  1762. X{
  1763. X    S_allocstr(to,strlen(from));
  1764. X    (void) strcpy(*to,from);
  1765. X    return;
  1766. X}
  1767. X
  1768. X/*
  1769. X**    save cnt characters of the string
  1770. X*/
  1771. Xvoid
  1772. XS_savenstr(to,from,cnt)
  1773. Xchar **to,*from;
  1774. X{
  1775. X    S_allocstr(to,cnt);
  1776. X    (void) strncpy(*to,from,cnt);
  1777. X    *((*to)+cnt) = '\0';
  1778. X    return;
  1779. X}
  1780. X
  1781. X/*
  1782. X**    allocate space for a string,  add 1 to size to
  1783. X**        make sure that there is room for the terminating null character
  1784. X*/
  1785. Xvoid
  1786. XS_allocstr(to,size)
  1787. Xchar **to;
  1788. Xint size;
  1789. X{
  1790. X    *to = Z_ALLOC(size+1,char);
  1791. X}
  1792. END_OF_FILE
  1793. if test 2859 -ne `wc -c <'strings.c'`; then
  1794.     echo shar: \"'strings.c'\" unpacked with wrong size!
  1795. fi
  1796. # end of 'strings.c'
  1797. fi
  1798. if test -f 'strings.h' -a "${1}" != "-c" ; then 
  1799.   echo shar: Will not clobber existing file \"'strings.h'\"
  1800. else
  1801. echo shar: Extracting \"'strings.h'\" \(693 characters\)
  1802. sed "s/^X//" >'strings.h' <<'END_OF_FILE'
  1803. X/*                        Copyright (c) 1988 Bellcore
  1804. X**                            All Rights Reserved
  1805. X**       Permission is granted to copy or use this program, EXCEPT that it
  1806. X**       may not be sold for profit, the copyright notice must be reproduced
  1807. X**       on copies, and credit should be given to Bellcore where it is due.
  1808. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1809. X*/
  1810. X
  1811. X#ifndef S_INCLUDED
  1812. Xextern void S_wordcpy();
  1813. Xextern void S_skipword();
  1814. Xextern void S_skipspace();
  1815. Xextern void S_nextword();
  1816. Xextern int  S_wordcmp();
  1817. Xextern void S_trimzeros();
  1818. Xextern void S_savestr();
  1819. Xextern void S_savenstr();
  1820. Xextern void S_allocstr();
  1821. X#define S_INCLUDED
  1822. X#endif
  1823. END_OF_FILE
  1824. if test 693 -ne `wc -c <'strings.h'`; then
  1825.     echo shar: \"'strings.h'\" unpacked with wrong size!
  1826. fi
  1827. # end of 'strings.h'
  1828. fi
  1829. if test -f 'token.c' -a "${1}" != "-c" ; then 
  1830.   echo shar: Will not clobber existing file \"'token.c'\"
  1831. else
  1832. echo shar: Extracting \"'token.c'\" \(823 characters\)
  1833. sed "s/^X//" >'token.c' <<'END_OF_FILE'
  1834. X/*                        Copyright (c) 1988 Bellcore
  1835. X**                            All Rights Reserved
  1836. X**       Permission is granted to copy or use this program, EXCEPT that it
  1837. X**       may not be sold for profit, the copyright notice must be reproduced
  1838. X**       on copies, and credit should be given to Bellcore where it is due.
  1839. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1840. X*/
  1841. X
  1842. X
  1843. X#ifndef lint
  1844. Xstatic char rcsid[]= "$Header: token.c,v 1.1 88/09/15 11:34:01 daniel Rel $";
  1845. X#endif
  1846. X
  1847. X#include "misc.h"
  1848. X#include "token.h"
  1849. X
  1850. XK_token _K_ato[K_MAXTOKENS]; /* storage for tokens */
  1851. XK_token _K_bto[K_MAXTOKENS];
  1852. X
  1853. Xint _K_atm;
  1854. Xint _K_btm;
  1855. X
  1856. Xvoid
  1857. XK_settoken(file,index,pointer)
  1858. Xint file;
  1859. Xint index;
  1860. XK_token pointer;
  1861. X{
  1862. X    if (file)
  1863. X    {
  1864. X        _K_bto[index] = pointer;
  1865. X    }
  1866. X    else
  1867. X    {
  1868. X        _K_ato[index] = pointer;
  1869. X    }
  1870. X}
  1871. END_OF_FILE
  1872. if test 823 -ne `wc -c <'token.c'`; then
  1873.     echo shar: \"'token.c'\" unpacked with wrong size!
  1874. fi
  1875. # end of 'token.c'
  1876. fi
  1877. if test -f 'token.h' -a "${1}" != "-c" ; then 
  1878.   echo shar: Will not clobber existing file \"'token.h'\"
  1879. else
  1880. echo shar: Extracting \"'token.h'\" \(2203 characters\)
  1881. sed "s/^X//" >'token.h' <<'END_OF_FILE'
  1882. X/*                        Copyright (c) 1988 Bellcore
  1883. X**                            All Rights Reserved
  1884. X**       Permission is granted to copy or use this program, EXCEPT that it
  1885. X**       may not be sold for profit, the copyright notice must be reproduced
  1886. X**       on copies, and credit should be given to Bellcore where it is due.
  1887. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1888. X*/
  1889. X
  1890. X
  1891. X#ifndef K_INCLUDED
  1892. X#include "float.h"
  1893. X#include "tol.h"
  1894. X#include "strings.h"
  1895. X
  1896. X#define        K_MAXTOKENS    50000
  1897. X/*
  1898. X**    values for token type
  1899. X*/
  1900. X#define K_LIT        1
  1901. X#define    K_FLO_NUM    2
  1902. X
  1903. X
  1904. Xtypedef struct {
  1905. X    int linenum;        /* line that the token started on */
  1906. X    int pos;        /* position on the line where token started */
  1907. X    int type;        /* token type */
  1908. X    char *text;         /* literal token text */
  1909. X    /*
  1910. X    **    canonical floationg point representation
  1911. X    */
  1912. X    F_float flo_num;
  1913. X    T_tol tolerance;
  1914. X} _K_str, *K_token;
  1915. X
  1916. X/*
  1917. X**    this should really be a two dimensional array
  1918. X**    but i'm too lazy to recode it
  1919. X*/
  1920. Xextern K_token _K_ato[];    /* storage for the tokens */
  1921. Xextern K_token _K_bto[];
  1922. X/*
  1923. X**    save token X from file
  1924. X*/
  1925. Xextern void K_settoken(/*file,X,ptr*/);
  1926. X#define K_gettoken(file, X)    (file?(_K_bto[X]):(_K_ato[X]))
  1927. X
  1928. Xextern int _K_atm;    /* count of tokens */
  1929. Xextern int _K_btm;
  1930. X
  1931. X/*
  1932. X**    get token number X from file
  1933. X*/
  1934. X#define K_get_token(file, X)    (file?(_K_bto[X]):(_K_ato[X]))
  1935. X
  1936. X#define K_gettmax(file)        (file?_K_btm:_K_atm)
  1937. X#define K_settmax(file,value)    (file?(_K_btm=(value)):(_K_atm=(value)))
  1938. X/*
  1939. X**    increment and return true on overflow
  1940. X*/
  1941. X#define    K_inctmax(file)        ((file?(++_K_btm):(++_K_atm))>=K_MAXTOKENS)
  1942. X
  1943. X#define K_setline(x,y)        (x->linenum = y)
  1944. X#define K_setpos(x,y)        (x->pos = y)
  1945. X#define K_settext(x,y)        (x->text = y)
  1946. X#define K_savetext(x,y,z)    S_savestr(&(x->text),y)
  1947. X#define K_saventext(x,y,z)    S_savenstr(&(x->text),y,z)
  1948. X#define K_setfloat(x,y)        (x->flo_num = y)
  1949. X#define K_settol(x,y)        (x->tolerance = y)
  1950. X#define K_settype(x,y)        (x->type = y)
  1951. X
  1952. X#define K_getline(x)        (x->linenum)
  1953. X#define K_getpos(x)        (x->pos)
  1954. X#define K_gettext(x)        (x->text)
  1955. X#define K_getfloat(x)        (x->flo_num)
  1956. X#define K_gettol(x)        (x->tolerance)
  1957. X#define K_gettype(x)        (x->type)
  1958. X
  1959. X#define K_maketoken()        (Z_ALLOC(1,_K_str))
  1960. X
  1961. X#define K_INCLUDED
  1962. X#endif
  1963. END_OF_FILE
  1964. if test 2203 -ne `wc -c <'token.h'`; then
  1965.     echo shar: \"'token.h'\" unpacked with wrong size!
  1966. fi
  1967. # end of 'token.h'
  1968. fi
  1969. if test -f 'tol.h' -a "${1}" != "-c" ; then 
  1970.   echo shar: Will not clobber existing file \"'tol.h'\"
  1971. else
  1972. echo shar: Extracting \"'tol.h'\" \(1754 characters\)
  1973. sed "s/^X//" >'tol.h' <<'END_OF_FILE'
  1974. X/*                        Copyright (c) 1988 Bellcore
  1975. X**                            All Rights Reserved
  1976. X**       Permission is granted to copy or use this program, EXCEPT that it
  1977. X**       may not be sold for profit, the copyright notice must be reproduced
  1978. X**       on copies, and credit should be given to Bellcore where it is due.
  1979. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1980. X*/
  1981. X
  1982. X#include "float.h"
  1983. X
  1984. X#ifndef T_INCLUDED
  1985. X/*
  1986. X**    values for tol_type
  1987. X*/
  1988. X#define T_ABSOLUTE         0
  1989. X#define T_RELATIVE         1
  1990. X#define T_IGNORE        2
  1991. X
  1992. Xtypedef struct _T_tstr{
  1993. X    int tol_type;        /* one of the above */
  1994. X    F_float flo_tol;    /* tolerance is expressed in
  1995. X                    terms of a floating point value */
  1996. X    struct _T_tstr *next;
  1997. X} _T_struct, *T_tol;
  1998. X
  1999. X#define _T_TOLMAX    10    /* number of tolerances that can
  2000. X                    be in effect at one time */
  2001. X
  2002. X#define _T_ADEF        "1e-10"    /* default absolute tolerance */
  2003. X#define _T_RDEF        "1e-10"    /* default relative tolerance */
  2004. X
  2005. Xextern T_tol T_gettol();
  2006. Xextern void T_clear_tols();
  2007. Xextern void T_initdefault();
  2008. Xextern void T_setdef();
  2009. Xextern void T_tolline();
  2010. Xextern T_tol T_picktol();
  2011. X
  2012. X#define T_gettype(x)    (x->tol_type)
  2013. X#define T_getfloat(x)    (x->flo_tol)
  2014. X#define T_getnext(x)    (x->next)
  2015. X
  2016. X#define T_settype(x,y)    (x->tol_type = y)
  2017. X#define T_setfloat(x,y)    (x->flo_tol = y)
  2018. X#define T_setnext(x,y)    (x->next = y)
  2019. X
  2020. X#define _T_null        ((T_tol) 0)
  2021. X#define T_isnull(x)    ((x) == _T_null)
  2022. X
  2023. Xextern T_tol _T_gtol;
  2024. Xextern void _T_addtol();
  2025. Xextern void _T_appendtols();
  2026. X
  2027. X/*
  2028. X**    routines for building the global tolerance list
  2029. X*/
  2030. X#define T_defatol(x)    _T_addtol(&_T_gtol,T_ABSOLUTE,x)
  2031. X#define T_defrtol(x)    _T_addtol(&_T_gtol,T_RELATIVE,x)
  2032. X#define T_defitol()    _T_addtol(&_T_gtol,T_IGNORE,(char*)NULL)
  2033. X
  2034. X#define _T_SEPCHAR    ';'
  2035. X
  2036. X#define T_INCLUDED
  2037. X#endif
  2038. END_OF_FILE
  2039. if test 1754 -ne `wc -c <'tol.h'`; then
  2040.     echo shar: \"'tol.h'\" unpacked with wrong size!
  2041. fi
  2042. # end of 'tol.h'
  2043. fi
  2044. if test -f 'visual.h' -a "${1}" != "-c" ; then 
  2045.   echo shar: Will not clobber existing file \"'visual.h'\"
  2046. else
  2047. echo shar: Extracting \"'visual.h'\" \(490 characters\)
  2048. sed "s/^X//" >'visual.h' <<'END_OF_FILE'
  2049. X/*                        Copyright (c) 1988 Bellcore
  2050. X**                            All Rights Reserved
  2051. X**       Permission is granted to copy or use this program, EXCEPT that it
  2052. X**       may not be sold for profit, the copyright notice must be reproduced
  2053. X**       on copies, and credit should be given to Bellcore where it is due.
  2054. X**       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  2055. X*/
  2056. X
  2057. X
  2058. X#ifndef V_INCLUDED
  2059. X
  2060. X
  2061. Xextern void V_cleanup();
  2062. X
  2063. X#define V_INCLUDED
  2064. X
  2065. X#endif
  2066. END_OF_FILE
  2067. if test 490 -ne `wc -c <'visual.h'`; then
  2068.     echo shar: \"'visual.h'\" unpacked with wrong size!
  2069. fi
  2070. # end of 'visual.h'
  2071. fi
  2072. echo shar: End of archive 1 \(of 4\).
  2073. cp /dev/null ark1isdone
  2074. MISSING=""
  2075. for I in 1 2 3 4 ; do
  2076.     if test ! -f ark${I}isdone ; then
  2077.     MISSING="${MISSING} ${I}"
  2078.     fi
  2079. done
  2080. if test "${MISSING}" = "" ; then
  2081.     echo You have unpacked all 4 archives.
  2082.     rm -f ark[1-9]isdone
  2083. else
  2084.     echo You still need to unpack the following archives:
  2085.     echo "        " ${MISSING}
  2086. fi
  2087. ##  End of shell archive.
  2088. exit 0
  2089.